Создайте класс Soda (для определения типа газированной воды), принимающий 1 аргумент при инициализации (отвечающий за добавку к выбираемому лимонаду). В этом классе реализуйте метод show_my_drink(), выводящий на печать «Газировка и {ДОБАВКА}» в случае наличия добавки, а иначе отобразится следующая фраза: «Обычная газировка».
При решении задания можно дополнительно проверить тип передаваемого аргумента: принимается только строка.
Решение: class Soda: def __init__(self, ingredient=None): if isinstance(ingredient, str): self.ingredient = ingredient else: self.ingredient = None
def show_my_drink(self): if self.ingredient: print(f'Газировка и {self.ingredient}') else: print('Обычная газировка')
Создайте класс Soda (для определения типа газированной воды), принимающий 1 аргумент при инициализации (отвечающий за добавку к выбираемому лимонаду). В этом классе реализуйте метод show_my_drink(), выводящий на печать «Газировка и {ДОБАВКА}» в случае наличия добавки, а иначе отобразится следующая фраза: «Обычная газировка».
При решении задания можно дополнительно проверить тип передаваемого аргумента: принимается только строка.
Решение: class Soda: def __init__(self, ingredient=None): if isinstance(ingredient, str): self.ingredient = ingredient else: self.ingredient = None
def show_my_drink(self): if self.ingredient: print(f'Газировка и {self.ingredient}') else: print('Обычная газировка')
Свой вариант решения в комментарии 💬
#задачи
BY Python Turbo. Уютное сообщество Python разработчиков.
Tata Power whose core business is to generate, transmit and distribute electricity has made no money to investors in the last one decade. That is a big blunder considering it is one of the largest power generation companies in the country. One of the reasons is the company's huge debt levels which stood at ₹43,559 crore at the end of March 2021 compared to the company’s market capitalisation of ₹44,447 crore.
NEWS: Telegram supports Facetime video calls NOW!
Secure video calling is in high demand. As an alternative to Zoom, many people are using end-to-end encrypted apps such as WhatsApp, FaceTime or Signal to speak to friends and family face-to-face since coronavirus lockdowns started to take place across the world. There’s another option—secure communications app Telegram just added video calling to its feature set, available on both iOS and Android. The new feature is also super secure—like Signal and WhatsApp and unlike Zoom (yet), video calls will be end-to-end encrypted.
Python Turbo Уютное сообщество Python разработчиков from kr